/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.pucp.dp1.TSPSolution.view;

/**
 *
 * @author walter
 */
public class Frm_ModificarServicio extends javax.swing.JPanel {

    /**
     * Creates new form Frm_ModificarServicio
     */
    public Frm_ModificarServicio() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        btnCancelarModServicio = new javax.swing.JButton();
        btnModificarServicio = new javax.swing.JButton();
        lblPorcSobreCosto = new javax.swing.JLabel();
        lblNombre = new javax.swing.JLabel();
        txtNombre = new javax.swing.JTextField();
        txtPorcSobreCosto = new javax.swing.JTextField();
        btnLimpiarModServicio = new javax.swing.JButton();

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Detalle Servicio"));

        btnCancelarModServicio.setText("Cancelar");
        btnCancelarModServicio.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnCancelarModServicioMouseReleased(evt);
            }
        });

        btnModificarServicio.setText("Guardar");
        btnModificarServicio.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnModificarServicioMouseReleased(evt);
            }
        });

        lblPorcSobreCosto.setText("Porc. sobre costo");

        lblNombre.setText("Nombre");

        txtNombre.setEditable(false);
        txtNombre.setText("Express");

        txtPorcSobreCosto.setText("19.5");

        btnLimpiarModServicio.setText("Limpiar");
        btnLimpiarModServicio.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnLimpiarModServicioMouseReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblNombre)
                            .addComponent(lblPorcSobreCosto))
                        .addGap(38, 38, 38)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtNombre)
                            .addComponent(txtPorcSobreCosto)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(45, 45, 45)
                        .addComponent(btnModificarServicio)
                        .addGap(44, 44, 44)
                        .addComponent(btnLimpiarModServicio)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE)
                        .addComponent(btnCancelarModServicio)
                        .addGap(34, 34, 34)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblNombre)
                    .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblPorcSobreCosto)
                    .addComponent(txtPorcSobreCosto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnModificarServicio)
                    .addComponent(btnCancelarModServicio)
                    .addComponent(btnLimpiarModServicio))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnModificarServicioMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnModificarServicioMouseReleased
        // TODO add your handling code here:
        int porcSobreCosto = 0 ;
        try{
            porcSobreCosto = Integer.parseInt( txtPorcSobreCosto.getText() ) ;
        }catch(Exception e ){
            
        }
        modificarServicio( porcSobreCosto ) ;
    }//GEN-LAST:event_btnModificarServicioMouseReleased

    private void modificarServicio( int porcSobreCosto ){
        // mostrar mensaje exito
        cerrar() ;
    }
    private void btnLimpiarModServicioMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnLimpiarModServicioMouseReleased
        // TODO add your handling code here:
        limpiar() ;
    }//GEN-LAST:event_btnLimpiarModServicioMouseReleased

    private void limpiar(){
        txtPorcSobreCosto.setText( "" ) ;
    }
    
    private void cerrar(){
        this.setVisible( false ) ;
    }
    
    private void btnCancelarModServicioMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCancelarModServicioMouseReleased
        // TODO add your handling code here:
        cerrar() ;
    }//GEN-LAST:event_btnCancelarModServicioMouseReleased

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelarModServicio;
    private javax.swing.JButton btnLimpiarModServicio;
    private javax.swing.JButton btnModificarServicio;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lblNombre;
    private javax.swing.JLabel lblPorcSobreCosto;
    private javax.swing.JTextField txtNombre;
    private javax.swing.JTextField txtPorcSobreCosto;
    // End of variables declaration//GEN-END:variables
}
